import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
// 预防用户关闭本地缓存造成浏览器抛出异常
let defaultHotListId = ''
try {
  if (localStorage.hotListId) {
    defaultHotListId = localStorage.hotListId
  }
} catch (e) {}

export default new Vuex.Store({
  state: {
    hotListId: defaultHotListId
  },
  mutations: {
    selectHotList (state, hotListId) {
      state.hotListId = hotListId
      try {
        // 设置本地缓存
        localStorage.hotListId = hotListId
      } catch (e) {}
    }
  }
})
